import moment from 'moment'
export default {
  namespaced: true,
  state: {
    ruleForm: {
      name: '', // 电影名
      cinema_name: '', // 影院
      hallName: '', // 影厅
      time: '', // 上映时间
      showDate: '', // 放映日期
      showTime: '', // 放映时间
      price: '' // 售价
    },
    isDialog: false,
    isAdd: true
  },
  mutations: {
    changeIsDialog (state, layload) {
      state.isDialog = layload
    },
    changeTime (state) {
      state.ruleForm.publicDate = moment(state.public_date).format('YYYY-MM-DD')
    },
    changeRuleForm (state, layload) {
      state.ruleForm = layload
    },
    changeIsAdd (state, layload) {
      state.isAdd = layload
    },
    changeRuleFormTime (state, layload) {
      state.ruleForm.time = layload
    }
  },
  actions: {
    // 显示弹框
    changeIsDialog ({ commit }, layload) {
      commit('changeIsDialog', layload)
    },
    // 处理时间格式
    changeTime ({ commit }) {
      commit('changeTime')
    },
    // 修改form
    changeRuleForm ({ commit }, layload) {
      commit('changeRuleForm', layload)
    },
    // 是否为添加
    changeIsAdd ({ commit }, layload) {
      commit('changeIsAdd', layload)
    },
    changeRuleFormTime ({ commit }, layload) {
      commit('changeRuleFormTime', layload)
    }
  }
}
